//
//  CagooXml.m
//  Cagoo
//
//  Created by brice rouanet on 02/02/10.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "CagooXml.h"


@implementation CagooXml

- (void)readXml:(NSString *)cagooConfFile
{
	NSString *file = [[NSString alloc] initWithString:cagooConfFile];
	NSXMLDocument *xmlDoc; 
    NSError *err=nil; 
    NSURL *furl = [NSURL fileURLWithPath:file]; 
	
    if (!furl) { 

        NSLog(@"Can’t create an URL from file %@.", file); 
        return; 
    } 
	
    xmlDoc = [ [NSXMLDocument alloc] initWithContentsOfURL:furl options:(NSXMLNodePreserveWhitespace|NSXMLNodePreserveCDATA) error:&err]; 
	
	if (xmlDoc == nil) { 
        xmlDoc = [[NSXMLDocument alloc] initWithContentsOfURL:furl 
													  options:NSXMLDocumentTidyXML 
														error:&err]; 
		NSLog(@"error");
    } 
	
	
	NSXMLElement *thisUser; 
	NSArray *nodes = [xmlDoc nodesForXPath:@"/cagoo/mountpoint" error:&err]; 
					  
					  if ([nodes count] > 0 ) { 
					  thisUser = [nodes objectAtIndex:0]; 
					  NSLog( [[thisUser childAtIndex:0 ] objectValue] );
					  // do something with element 
					  } 
					  
					  NSLog(@"hurey");
}


@end
